Event encounters
This page describes how to begin a wild Pokémon encounter on demand. These are typically used for non-roaming legendary encounters, and for any other Pokémon you battle after interacting with it in the overworld (e.g. Voltorb that look like item balls). Wild battles caused by an event Event encounters are typically those where the Pokémon to be battled appears as a sprite in the overworld, and interacting with that sprite leads to a wild encounter with that Pokémon. It can also be used to set up traps (whose events will have a blank graphic and will activate upon Player Touch). The main part of the event is the following line of code: pbWildBattle(:species,level,result,escape,canlose) * "species" - The internal name of the species of the Pokémon to be encountered. Note the colon before it. * "level" - The level of the Pokémon * "result" - Optional. A Game Variable number in which the outcome of the battle will be recorded (1=won, 2=lost, 3=run, 4=caught, 5=draw). * "escape" - Optional. false if the player is not allowed to flee from the battle (true by default). * "canlose" - Optional. true if the game continues even if the player loses the battle (with the player's party fully healed) (false by default; the player will black out if they lose). The event typically consists of two pages: * Page 1 - Contains a call to pbWildBattle. * Page 2 - Blank, and depends on the event's Self Switch A being ON. In most cases, the encounter can only be done once, which means that after the battle, regardless of the outcome, the event should go to page 2. Simply set the event's Self Switch A to ON immediately after the battle. If the event Pokémon will only disappear because of certain battle outcomes (e.g. because of a win, capture or flee, but not because of a loss), then you will need to save the battle's result to a variable as described above. After the call to pbWildBattle, instead of simply setting the event's Self Switch A, you should create one or more Conditional Branches which check the saved outcome value and do things accordingly. Double wild battles These events are set up in the same way as single event encounters. The only difference is the code used to start the battle: pbDoubleWildBattle(:species1,level1,:species2,level2,result,escape,canlose) This works in the same way as pbWildBattle, except a second species (and level) is also defined. Examples pbWildBattle(:KECLEON,20) This triggers an encounter with a Level 20 Kecleon. The outcome of the battle is not recorded anywhere, and the player can flee from the battle. pbDoubleWildBattle(:PIKACHU,21,:CLEFAIRY,17) This triggers a double wild encounter with a Level 21 Pikachu and a Level 17 Clefairy. The outcome of the battle is not recorded anywhere, and the player can flee from the battle. pbWildBattle(:MEWTWO,70,1,false,true) This triggers an encounter with a Level 70 Mewtwo. The outcome of the battle is stored in Game Variable 1, and the player cannot run from the battle. If the player loses the battle against Mewtwo, their party will be fully healed instead of them blacking out. Modifying the Pokémon It is possible to modify many attributes of a wild Pokémon encountered via an event (e.g. make it shiny, choose its gender, change its stats, moveset, etc.). The method described below is the best way of editing a wild Pokémon encountered in an event encounter. Firstly, define a Game Switch that will cause one of these modifications (e.g. making the Pokémon shiny). Then, in the script section PField_EncounterModifiers, you will find (something similar to) the following: Events.onWildPokemonCreate += proc{|sender,e| pokemon = e0 if $game_switches31 pokemon.makeShiny end } This code will take the Pokémon generated at the start of any wild encounter and allow its attributes to be edited. In this example, the Pokémon is made shiny if Game Switch 31 is ON. For event encounters, it is simplest to allow an edit to be made only if a certain Game Switch is ON, because you can easily toggle it ON and OFF in the same event that triggers the battle. Once you have written your own version of the code above, in the event that triggers the battle, turn the Game Switch you have chosen ON immediately before the call to pbWildBattle and OFF immediately afterwards, like so: @>Control Switches: Shiny wild Pokémon = ON @>Script: pbWildBattle(:GYARADOS,30) @>Control Switches: Shiny wild Pokémon = OFF It is important that the Game Switch be turned OFF again immediately afterwards, because if it isn't, all future wild encounters will also be shiny (or have whatever edited attributes you chose). Tips * You can combine an event encounter with a time-sensitive event, in order to have a Pokémon that only appears at certain times. ** Alternatively, the Pokémon could return some time after it was battled, ready for re-battling. Typically, this would only be done if the battle was lost or fled from (and not if the Pokémon was defeated or captured) - take advantage of the ability to store the outcome of the battle in order to achieve this. * Set traps for the player by springing wild Pokémon encounters on them in specific places (an example in the games is the Team Rocket HQ under Mahogany Town). Simply don't give the event a sprite, and have it trigger when stepped on rather than interacted with. * You could make the Pokémon begin roaming if the battle is lost or fled. * Invent certain battle conditions that depend on a Game Switch being ON (e.g. all Poké Balls used will always fail, or the weather randomly changes every turn), and turn that Switch ON just before the battle (and OFF again afterwards, of course). In this way, you can customise certain wild encounters to make them unique/harder. * Have the Pokémon drop something if it is defeated. Edit page 2 of the event accordingly to turn the event into an item ball. * Allow the battle to take place only if the player has a certain Key Item (e.g. the Devon Scope for invisible Kecleon), and have the event be unresponsive and simply block the player's progress otherwise.